/***************************************************************
|	File:		InstructionState.cpp
|	Author:		John Gawne
|	Course:		Structure of Game Design
|	Purpose:	InstructionState class creates the instructions menu state
***************************************************************/
#include "InstructionState.h"
#include "../SGD Wrappers/SGD_AudioManager.h"
#include "../SGD Wrappers/SGD_GraphicsManager.h"
#include "../SGD Wrappers/SGD_InputManager.h"

#include "Game.h"
#include "BitmapFont.h"
#include "GameplayState.h"
#include "MainMenuState.h"
#include "Credits.h"

/*static*/ InstructionState* InstructionState::GetInstance(void)
{
	static InstructionState s_Instance;

	return &s_Instance;
}

void InstructionState::Enter(void)
{

	m_hInstBackground = SGD::GraphicsManager::GetInstance()->LoadTexture(L"resource/graphics/JAG_Credits_Menu.png");
	m_hPlayer = SGD::GraphicsManager::GetInstance()->LoadTexture(L"resource/graphics/JAG_Player.png");
	m_hEnemy = SGD::GraphicsManager::GetInstance()->LoadTexture(L"resource/graphics/JAG_Enemy.png");

}

void InstructionState::Exit(void)
{

	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hInstBackground);
	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hPlayer);
	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hEnemy);
}

bool InstructionState::Input(void)
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();




	// Select an option?
	if (pInput->IsKeyPressed(SGD::Key::Escape) == true)
	{

		Game::GetInstance()->ChangeState(MainMenuState::GetInstance());

	}

	return true;	// keep playing
}

void InstructionState::Render(void)
{
	// Use the game's font
	SGD::GraphicsManager::GetInstance()->DrawTexture(m_hInstBackground, SGD::Point{ 0, 0 }, 0.0f, {}, {}, { 2, 3 });
	BitmapFont* pFont = Game::GetInstance()->GetFont();

	// Align text based on window width
	int width = Game::GetInstance()->GetScreenWidth();


	// Display the game title centered at 4x scale
	pFont->Draw("Instructions", (int)(width - (12 * 32 * 1.0f)) / 2, 10, 1.0f, {});

	// Display the menu options centered at 1x scale
	pFont->Draw("You play as", (int)(width - (13 * 32 * 0.5f)) / 2, 100, 0.5f, {});


	SGD::GraphicsManager::GetInstance()->DrawTextureSection(
		m_hPlayer, SGD::Point{480, 150}, {0, 0,98, 154 }, 0, {}, {}, SGD::Size{0.5f, 0.5f});

	pFont->Draw("Use the WASD keys to move around", (int)(width - (32 * 32 * 0.5f)) / 2, 250, 0.5f, {});
	pFont->Draw("and the mouse to aim and shoot", (int)(width - (30 * 32 * 0.5f)) / 2, 300, 0.5f, {});
	pFont->Draw("Your target is", (int)(width - (14 * 32 * 0.5f)) / 2, 350, 0.5f, {});

	SGD::GraphicsManager::GetInstance()->DrawTextureSection(
		m_hEnemy, SGD::Point{480, 400}, {0, 0,48,48 });

	pFont->Draw("Kill all enemys to win", (int)(width - (23 * 32 * 0.5f)) / 2, 450, 0.5f, {});



	/*pFont->Draw("at", (int)(width - (2 * 32 * 0.5f)) / 2, 400, 0.5f, {});
	pFont->Draw("Full Sail University", (width - (20 * 32 * 0.5f)) / 2, 450, 0.5f, {});*/

	pFont->Draw("Press \"Escape\" to Continue", (int)(width - (24 * 32 * 0.5f)) / 2, 550, 0.5f, {});


	//	pFont->Draw( "Exit", (width - (4 * 32))/2, 400, 1.0f, {} );	
}

/*virtual*/ void InstructionState::Update( float elapsedTime )
{
}
